<!DOCTYPE html>
<html lang="en" class="no-js" xmlns:th="http://www.thymeleaf.org"
	xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
	layout:decorator="layout">
<head>
<title>哗啦啦</title>
</head>
<body>
	<div layout:fragment="content">
		<div class="col-md-12">
			<div class="area game">
				<div class="top1">
					<div class="col-md-3"></div>
					<div class="col-md-6">
						<div th:replace="game/gamehead"></div>
					</div>
					<div class="col-md-3"></div>
				</div>
				<div class="blank"></div>
				<div
					style="border: 1px solid #ccc; border-radius: 4px; padding: 5px;">
					<div class="top2" th:include="game/gamesubhead"></div>
					<div class="blank"></div>
					<div class="newcp">
							<div class="blank"></div>
							<div style=" text-align:center; line-height:26px;">
								<div>
									<table class="tb1" cellspacing="0" cellpadding="3" rules="cols" style="color:Black;background-color:White;border-color:#999999;border-width:1px;border-style:Solid;width:100%;border-collapse:collapse;">
										<th:block th:if="${#lists.isEmpty(permutationBets)}">
											<tr>
												<td colspan="4">无对号投注</td>
											</tr>
										</th:block>
										<th:block th:unless="${#lists.isEmpty(permutationBets)}">
											<tr style="color:White;background-color:Black;font-weight:bold;">
												<th>状态</th>
												<th>操作</th>
											</tr>
											<tr th:each="permutationBet:${permutationBets}">
												<td><font class="gr" th:text="${permutationBet.state.description}"></font></td>
												<td>
													<a href="#" th:href="@{'/fgame/'+${game.id}+'/permutation?permutationId='+${permutationBet.id}}" class="btn default btn-xs purple" >编辑</a>
													<a href="#" th:if="${permutationBet.state.description == '正在运行'}" th:href="@{'/fgame/'+${game.id}+'/stoppermutationbet?autoId='+${permutationBet.id}}" class="btn default btn-xs purple" >ͣ停止</a>
													<a href="#" th:if="${permutationBet.state.description != '正在运行'}" th:href="@{'/fgame/'+${game.id}+'/stoppermutationbet?permutationId='+${permutationBet.id}}" class="btn default btn-xs purple" disabled = "disabled">停止ֹ</a>
													<a href="#" th:href="@{'/fgame/'+${game.id}+'/fromheadpermutationbet?permutationId='+${permutationBet.id}}" class="btn default btn-xs purple" >从头运行</a>
													<a href="#" th:if="${permutationBet.state.description != '正在运行'}" th:href="@{'/fgame/'+${game.id}+'/keepgopermutationbet?permutationId='+${permutationBet.id}}" class="btn default btn-xs purple" >继续运行</a>
													<a href="#" th:if="${permutationBet.state.description == '正在运行'}" th:href="@{'/fgame/'+${game.id}+'/keepgopermutationbet?permutationId='+${permutationBet.id}}" class="btn default btn-xs purple" disabled = "disabled">继续运行</a>
													<a href="#" th:href="@{'/fgame/'+${game.id}+'/deletepermutationbet?permutationId='+${permutationBet.id}}" class="btn default btn-xs purple" >删除</a>
												</td>
											</tr>
										</th:block>
									</table>
								</div>
							</div>
							<div class="blank"></div>

							<div class="blank"></div>
							<table cellspacing="1" border="1" width="100%" class="ctb">
								<tr>
							    	<td class="tdo1" valign="top">
							    	<div style="height: 30px; line-height: 30px; font-weight: bold; font-size: 16px; font-family: 微软雅黑; color:#FFF; background-color:#063; text-indent: 15px">
										<span id="ContentPlaceHolder1_ContentPlaceHolder1_Label1">新建</span>
									</div>
							<form id="auto_bet_form" th:object="${permutationBet}" th:action = "${'/fgame/'+game.id+'/savePermutation'}" method="post">
							        <table border="0" width="100%" class="ltb">
							            	<tr>
							                	<td class="td2">方案名称：</td>
							                    <td>
							                    	<input id="auto_bet_name" th:field="*{name}" name="autoBet.name" type="text" class="allte" />
							                    </td>
							                </tr>
							            	<tr>
							                	<td class="td2">开始期数</td>
							                    <td>
							                    	<input type="hidden" id="auto_bet_id" th:field="*{id}" />
							                    	<input th:field="*{startBetPeriod}"  type="text"  class="allte" />
							                    </td>
							                </tr>
							            	<tr>
							                	<td class="td2">执行期数</td>
							                    <td>
							                    	<input th:field="*{executePeriod}" type="text" class="allte" />
							                    </td>
							                </tr>
							            	<tr>
							                	<td class="td2">金币上限:</td>
							                    <td>
							                    	<input th:field="*{superLimit}" type="text" class="allte" />
							                    </td>
							                </tr>
							            	<tr>
							                	<td class="td2">金币下限:</td>
							                    <td>
							                    	<input th:field="*{lowerLimit}" type="text" class="allte" />
							                    </td>
							                </tr>
							            </table>
							            <input type="hidden" id="detail" name="detail" />
	    							</form>
							        </td>
							        <td class="tdo2" valign="top">
							        	<div>
											<table id="detail_table" class="tb22" cellspacing="0" cellpadding="4"  style="color:#333333;width:100%;border-collapse:collapse;">
												<tr style="color:White;background-color:#1C5E55;font-weight:bold;">
													<th>选择</th>
													<th>号码</th>
													<th>模式</th>
												</tr>
												<th:block th:if="${permutationBet.id == null}">
													<tr class="aunum" style="background-color:#E3EAEB;" th:each="detail:${details}">
														<td>
											                 <input type="checkbox" th:attr="id=${'checkbox_'+detail.betNumber}" onclick="aunumselect(this);" />
											            </td>
											            <td>
											                 <div class="gamebnum" th:classappend="${'gamebn'+detail.betNumber}"></div>
											            </td>
											            <td>
											                 <select  th:attr="id=${'select_'+detail.betNumber}" disabled="disabled" class="aspNetDisabled allte">
															 	<option th:each="model2:${models}" th:text="${model2.name}" th:value="${model2.id}"></option>
															 </select>
											            </td>
													</tr>
												</th:block>
												<th:block th:if="${permutationBet.id != null}">
													<tr class="aunum" style="background-color:#E3EAEB;" th:each="detail:${details}">
														<td>
											                 <input type="checkbox" th:attr="id=${'checkbox_'+detail.betNumber},checked=${detail.cathecticModelId == 0?'false':'checked'}" onclick="aunumselect(this);" />
											            </td>
											            <td>
											                 <div class="gamebnum" th:classappend="${'gamebn'+detail.betNumber}"></div>
											            </td>
											            <td>
											                 <select  th:attr="id=${'select_'+detail.betNumber}" th:disabled="${detail.cathecticModelId == 0?'disabled':'false'}" class="allte" th:classappend="${detail.cathecticModelId == 0?'aspNetDisabled':''}">
															 	<option th:each="model2:${models}" th:selected="${detail.cathecticModelId == model2.id}" th:text="${model2.name}" th:value="${model2.id}"></option>
															 </select>
											            </td>
													</tr>
												</th:block>
											</table>
										</div>
							        </td>
							    </tr>
							</table> 
							<div class="blank"></div>
							<div>
	    						<input type="button"  value="确定" onclick="checkOnsubmit()" class="nbtn" style="font-size:Large;" />
	    						<span  style="color:#993300;"></span>
	    					</div>
						</div>
						<div class="blank"></div>
						<div class="blank"></div>
						<div>
                            <strong>帮助：</strong>
                			确认并开始自动投注后，系统将会在你指定的期数内帮您自动投注，不论你的离线或在线都会持续运 行直到期数终止或您关闭为止。<br />
                		</div>
                		<script type="text/javascript">
                		function aunumselect(obj) {
                	        if ($(obj).parent().parent().find('.allte').attr('disabled')) {
                	            $(obj).parent().parent().find('.allte').removeAttr('disabled');
                	        } else {
                	            $(obj).parent().parent().find('.allte').attr('disabled', "true");
                	        }
                	    }
                			function checkOnsubmit(){
                				if(!$('#auto_bet_name').val()){
                					alert('请填写对号投注名称！！')
                					return false;
                				}
                				if(!$('#detail_table input:checked').length){
                					alert('请至少选择一个号码！！');
                					return false;
                				}
                				var detail_json = '[';
                				$('#detail_table input:checked').each(function(){
                					var modelId = $(this).attr('id').split('_')[1];
                					detail_json = 
                						(detail_json+'{"betNumber":'+modelId+',"cathecticModelId":'+
                							$('#select_'+modelId).val()+'},');
                					
                				});
                				detail_json = detail_json.slice(0,-1);
                				detail_json = detail_json+']';
                				$('#detail').val(detail_json);
                				$('#auto_bet_form').submit();
                			}
                		</script> 
				</div>
			</div>
		</div>
	</div>
</body>
</html>